<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">


    <ui:composition template="/master.xhtml">

          <ui:define name="menu">
            <ui:include src="../menu.xhtml" /> 
        </ui:define>
        
      
        <ui:define name="TituloModulo">

            Gestão de Utilizadores
        </ui:define>

        <ui:define name="TituloConteudoPrincipal">
           Lista de Utilizadores
        </ui:define>


        <ui:define name="ConteudoPrincipal">
            <h:form>
                <p:messages globalOnly="true"/>

                <h:outputText escape="false" value="Não existem usuários registados" rendered="#{loginUsuarioController.items.rowCount == 0}"/>
                <p:outputPanel  rendered="#{loginUsuarioController.items.rowCount > 0}">
                    <h:outputText value="#{loginUsuarioController.pagination.pageFirstItem + 1}..#{loginUsuarioController.pagination.pageLastItem + 1}/#{loginUsuarioController.pagination.itemsCount}"/>&nbsp;
                    <p:commandLink ajax="false" actionListener="#{loginUsuarioController.previous}" value="#{bundle01.anterior} #{loginUsuarioController.pagination.pageSize}" rendered="#{loginUsuarioController.pagination.hasPreviousPage}"/>&nbsp;
                    <p:commandLink ajax="false" actionListener="#{loginUsuarioController.next}" value="#{bundle01.posterior} #{loginUsuarioController.pagination.pageSize}" rendered="#{loginUsuarioController.pagination.hasNextPage}"/>&nbsp;
                    <p:dataTable value="#{loginUsuarioController.items}" var="item" >

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle01.nomeUsuario}"/>
                            </f:facet>
                            <h:outputText value="#{item.nomeUsuario}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle01.tipoUsuario}"/>
                            </f:facet>
                            <h:outputText value="#{item.fkTipoUsuario.designacao}"/>
                        </p:column>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle01.cadastrador}"/>
                            </f:facet>
                            <h:outputText value="#{item.fkLoginCadastrador.nomeUsuario}"/>
                        </p:column>

                        <p:column>
                           
                            <p:menuButton value="Opções">

                                <p:menuitem value="#{bundle01.ver}"  
                                            action="#{loginUsuarioController.prepareView}" 
                                            icon="ui-icon-extlink" ajax="false"/>

                                <p:menuitem value="#{bundle01.editar}" ajax="false"   
                                            action="#{loginUsuarioController.prepareEdit}"  
                                            icon="ui-icon-arrowrefresh-1-w" />

                                <p:menuitem value="#{bundle01.eliminar}" icon="ui-icon-close"  
                                             ajax="false"  action="#{loginUsuarioController.destroy}"/>
                            </p:menuButton>

                        </p:column>
                    </p:dataTable>
                </p:outputPanel>

                <p:commandButton ajax="false" action="#{loginUsuarioController.prepareCreate}" value="#{bundle01.criar}"/>

            </h:form>
         </ui:define>
    </ui:composition>
</html>
